#!/usr/bin/env node

import initServerInstance from '../initServerInstance';
import systemRepeatTasks from './index';

// eslint-disable-next-line no-extend-native
Object.defineProperty(Error.prototype, 'toJSON', {
	value: function getJsonValue() {
		return Object.getOwnPropertyNames(this).reduce((obj, key) => {
			if (typeof key !== 'string') return obj;
			obj[key] = this[key];
			return obj;
		}, {});
	},
	configurable: true,
	writable: true,
});

process.on('unhandledRejection', reason => {
	console.error({ reason }, 'Unhandled Rejection');
});

(async () => {
	const server = await initServerInstance({
		loggerConfig: {
			name: 'systemRepeatTask',
			alwaysCreate: true,
		},
	});
	await systemRepeatTasks(server);
})();
